package com.cn.dream_order_server.async;


import com.cn.dream_order_server.pojo.OrderLogistics;
import com.cn.dream_order_server.service.OrderLogisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.concurrent.Future;

@Component
@Async
public class DeliverGoodsAsync {

    @Autowired
    private OrderLogisticsService orderLogisticsService;

    public Future<Integer> deliverGoods(String logisticsId, String logisticstypeId){
        OrderLogistics logistics = new OrderLogistics();
        logistics.setLogisticsId(logisticsId);
        logistics.setShipmentsTime(new Date());
        logistics.setLogisticstypeId(logisticstypeId);
        logistics.setLogisticsstatusId("1");
        return new AsyncResult<Integer>(orderLogisticsService.savaOrderLogistics(logistics));
    }

    public void doDeliveryTime(OrderLogistics orderLogistics){
        orderLogisticsService.updateOrderLogisticsByOrderLogisticsId(orderLogistics);
    }
}
